import java.util.Arrays;
import java.util.Random;

public class TestSort {
    public static void testinsertSort(int[] array){
        array = Arrays.copyOf(array, array.length);
        long startTime = System.currentTimeMillis();
        Sort.insertSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("插入排序耗时：" + (endTime - startTime));
    }
    public static void testshellSort(int[] array){
        array = Arrays.copyOf(array, array.length);
        long startTime = System.currentTimeMillis();
        Sort.shellSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("希尔排序耗时：" + (endTime - startTime));
    }
    public static void testquickSort(int[] array){
        array = Arrays.copyOf(array, array.length);
        long startTime = System.currentTimeMillis();
        Sort.quickSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("快速排序耗时：" + (endTime - startTime));
    }
    public static void testquickSort3(int[] array){
        array = Arrays.copyOf(array, array.length);
        long startTime = System.currentTimeMillis();
        Sort.quickSort3(array);
        long endTime = System.currentTimeMillis();
        System.out.println("非递归快速排序优化后耗时：" + (endTime - startTime));
    }
    //创建随机数组
    public static void norArray(int[] array){
        Random random = new Random();
        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(100_0000);
        }
    }
    //创建有序数组
    public static void orderArray(int[] array){
        for (int i = 0; i < array.length; i++) {
            array[i] = array.length - i;
        }
    }
    public static void main(String[] args) {
        Sort sort = new Sort();
        int[] array = {6, 1, 2, 7, 9, 11, 4, 5, 10, 8, 263, 23, 67, 34, 86, 297, 186, 92, 166, 28363, 5763};
//        Sort.quickSort3(array);
        Sort.mergeSort(array);
        System.out.println(Arrays.toString(array));
//        int[] array = new int[10_0000];
//        norArray(array);
////        orderArray(array);//逆序
//        testinsertSort(array);
//        testshellSort(array);
////        testquickSort(array);
//        testquickSort3(array);
    }
}
